Class sjl.SingleList
All Packages Class Hierarchy This Package Previous Next Index
Class sjl.SingleList
java.lang.Object
|
+----sjl.SingleList
- public class SingleList
- extends Object
- implements FrontInsertContainer
SingleList
is a kind of sequence that supports forward iterators
and allow constant time insert and erase operations anywhere within the
sequense, with storage management handled automatically. Unlike vectors
and deques, fast random access to list elements are not suported,
but many algorithms only need sequential access anyway.
insert
does not affect the validity of iterators.
Insertion of a single element into a list takes constant time.
Insertion of multiple elements into a list is linear in the number of
elements inserted.
erase
invalidates only the iterators to the erased elements.
Erasing a single element is constant time.
Erasing a range in a list is linear time in the size of the range.
Copyright © 1996 Finn Bock
-
SingleList()
- Constructs an empty list.
-
SingleList(InputIterator, InputIterator)
- Constructs a list with elements found in the range
[first,last)
.
-
SingleList(int, Object)
- Constructs a list with
n
element each pointing to value.
-
SingleList(SingleList)
- Constructs a list with all the elements from another list.
-
back()
- Returns the last element in the list.
-
begin()
- Returns the iterator that represents the beginning of the list.
-
beginGeneric()
- Returns the iterator that represents the beginning of the list as a
untyped iterator.
-
beginRef()
- Returns a reference to the iterator that represents the
beginning of the list.
-
empty()
- Returns
true
if the list does not contain any elements.
-
end()
- Returns the iterator that represents the end of the list.
-
endGeneric()
- Returns the iterator that represents the end of the list as a
untyped iterator.
-
endRef()
- Returns a reference to the iterator that represents the end of the list.
-
equals(Object)
- Compare the elements in this container with the elements
in another container.
-
erase(Iterator)
- Remove the element to which the iterator points.
-
erase(Iterator, Iterator)
- Remove the elements in the range
[first,last)
from the list.
-
flush()
-
Erase all the elements in the container.
-
front()
- Returns the first element in the list.
-
insert(Iterator, InputIterator, InputIterator)
- Insert the element in the range
[first,last)
into the list
at the specified position.
-
insert(Iterator, int, Object)
- Insert
n
copy of the element at the specified position.
-
insert(Iterator, Object)
- Insert the element at the specified position.
-
max_size()
- Returns the maximum number of elements allowed in the list.
-
merge(SingleList, Predicate2)
- Merge merges the argument list into this list
(both are assumed to be sorted).
-
pop_front()
- Remove the first element in the list.
-
push_back(Object)
- Insert at the end of the list.
-
push_front(Object)
- Insert at the beginning of the list.
-
remove(Object)
- Remove all elements in the list where the element is equals to the
value.
-
reverse()
- Reverse reverses the oerder of the element in the list.
-
size()
- Returns the number of elements stored in the list.
-
sort(Predicate2)
- Sort sorts the list according to the compare function object.
-
splice(Iterator, SingleList)
- Insert the contents of another list into this list before position.
-
splice(Iterator, SingleList, Iterator)
- Insert the element pointed to by the iterator
i
from
another list into this list before a position.
-
splice(Iterator, SingleList, Iterator, Iterator)
- Insert elements in the range into this list and remove the
elements from the other list.
-
splice(SingleList)
- Insert elements from another list into this list and remove the
elements from the other list.
-
splice(SingleList, Iterator)
- Insert an element from another list into this list and remove the
element from the other list.
-
swap(SingleList)
- Swaps the contents of the current list with those of the input list.
-
unique()
- Unique erases all but the first element from every
consecutive group of equal element in the list.
SingleList
public SingleList()
- Constructs an empty list.
SingleList
public SingleList(int n,
Object value)
- Constructs a list with
n
element each pointing to value.
- Parameters:
- n - The number of elements the list will contain.
- value - The object that is inserted in each in the list.
SingleList
public SingleList(InputIterator first,
InputIterator last)
- Constructs a list with elements found in the range
[first,last)
.
- Parameters:
- first - The beginning of the range.
- last - The end of the range.
SingleList
public SingleList(SingleList list)
- Constructs a list with all the elements from another list.
- Parameters:
- list - The elements in this list is copied into the newly
contructed list.
flush
public void flush()
- Erase all the elements in the container.
swap
public void swap(SingleList x)
- Swaps the contents of the current list with those of the input list.
The current list replaces x and vice versa.
equals
public boolean equals(Object container)
- Compare the elements in this container with the elements
in another container.
- Returns:
-
true
is the elements match.
- Overrides:
- equals in class Object
begin
public ForwardIterator begin()
- Returns the iterator that represents the beginning of the list.
beginRef
public ForwardIterator beginRef()
- Returns a reference to the iterator that represents the
beginning of the list.
end
public ForwardIterator end()
- Returns the iterator that represents the end of the list.
endRef
public ForwardIterator endRef()
- Returns a reference to the iterator that represents the end of the list.
beginGeneric
public ForwardIterator beginGeneric()
- Returns the iterator that represents the beginning of the list as a
untyped iterator.
endGeneric
public ForwardIterator endGeneric()
- Returns the iterator that represents the end of the list as a
untyped iterator.
front
public Object front()
- Returns the first element in the list.
back
public Object back()
- Returns the last element in the list.
size
public int size()
- Returns the number of elements stored in the list.
max_size
public int max_size()
- Returns the maximum number of elements allowed in the list.
empty
public boolean empty()
- Returns
true
if the list does not contain any elements.
push_front
public void push_front(Object value)
- Insert at the beginning of the list.
- Parameters:
- value - the element to insert.
push_back
public void push_back(Object value)
- Insert at the end of the list.
- Parameters:
- value - the element to insert.
insert
public Iterator insert(Iterator position,
Object value)
- Insert the element at the specified position.
- Parameters:
- position - An iterator that points to the position where
the element is inserted.
- value - The element.
insert
public void insert(Iterator position,
int n,
Object value)
- Insert
n
copy of the element at the specified position.
- Parameters:
- position - An iterator that points to the position where
the elements are inserted.
- n - The number of elements.
- value - The element.
insert
public void insert(Iterator position,
InputIterator first,
InputIterator last)
- Insert the element in the range
[first,last)
into the list
at the specified position.
- Parameters:
- position - An iterator that points to the position where
the elements are inserted.
- first - The beginning of the range
- last - The end of the range
pop_front
public void pop_front()
- Remove the first element in the list.
erase
public void erase(Iterator position)
- Remove the element to which the iterator points.
- Parameters:
- position - the element to which the iterator point is removed.
erase
public void erase(Iterator first,
Iterator last)
- Remove the elements in the range
[first,last)
from the list.
- Parameters:
- first - The beginning of the range.
- last - The end of the range.
splice
public void splice(Iterator position,
SingleList x)
- Insert the contents of another list into this list before position.
All elements are removed from the other list. Essentially the
contents of the orther list is transferred in into this list.
- Parameters:
- position - The elements are inserted before this position.
- x - The source list.
splice
public void splice(Iterator position,
SingleList x,
Iterator i)
- Insert the element pointed to by the iterator
i
from
another list into this list before a position.
The element is removed from the other list.
- Parameters:
- position - The elements are inserted before this position.
- x - The source list.
- i - The source element.
splice
public void splice(Iterator position,
SingleList x,
Iterator first,
Iterator last)
- Insert elements in the range into this list and remove the
elements from the other list.
Elements in the range
[first, last)
is inserted into
this list before position. The elements are removed from the other list.
- Parameters:
- position - The elements are inserted before this position.
- x - The source list.
- first - The beginning of the range.
- last - The end of the range.
splice
public void splice(SingleList x)
- Insert elements from another list into this list and remove the
elements from the other list.
- Parameters:
- x - The source list.
splice
public void splice(SingleList x,
Iterator position)
- Insert an element from another list into this list and remove the
element from the other list.
- Parameters:
- x - The source list.
- position - The element which will be inserted.
remove
public void remove(Object value)
- Remove all elements in the list where the element is equals to the
value. Remove is stable, that is, the relative order of the
elements that not removed is the same as their relative order in
the original list.
- Parameters:
- value - The value that the elements are compared with.
unique
public void unique()
- Unique erases all but the first element from every
consecutive group of equal element in the list.
value. Remove is stable, that is, the relative order of the
elements that not removed is the same as their relative order in
the original list.
- Parameters:
- value - The value that the elements are compared with.
merge
public void merge(SingleList x,
Predicate2 pred)
- Merge merges the argument list into this list
(both are assumed to be sorted).
The merge is stable, that is, for equal elements in the two lists,
the elements from this list always precede elements from the
argument list. The argument list is empty after the merge.
- Parameters:
- x - The list that is merge into this list.
reverse
public void reverse()
- Reverse reverses the oerder of the element in the list.
sort
public void sort(Predicate2 pred)
- Sort sorts the list according to the compare function object. It is
stable, that is, the relative order of the equal elements is preserved.
All Packages Class Hierarchy This Package Previous Next Index